package com.taxi.driver.module.order.detail;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.taxi.driver.R;
import com.taxi.driver.common.BaseActivity;
import com.taxi.driver.config.IConstants;
import com.taxi.driver.module.amap.AMapFragment;

/**
 * 功能描述：订单详情
 */
public class OrderDetailActivity extends BaseActivity {

    private static final String KEY_ORDER_UUID = "ORDER_UUID";
    private static final String STATUS = "";

    AMapFragment mAMapFragment;
    OrderDetailFragment mOrderDetailFragment;
    private int isCancle;

    public static void start(Context context, String orderUuid,Integer state) {
        Intent starter = new Intent(context, OrderDetailActivity.class);
        starter.putExtra(KEY_ORDER_UUID, orderUuid);
        starter.putExtra(STATUS, state);
        context.startActivity(starter);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_detail);
        String orderUuid = getIntent().getStringExtra(IConstants.ORDER_UUID);
        isCancle = getIntent().getIntExtra(STATUS,0);
        boolean refresh = getIntent().getBooleanExtra(IConstants.REFRESH, false);
        if (mOrderDetailFragment == null)
            addFragment(R.id.order_container, OrderDetailFragment.newInstance(orderUuid, refresh, isCancle));
        if (mAMapFragment == null) addFragment(R.id.map_container, AMapFragment.newInstance());
    }

    @Override
    public void onAttachFragment(Fragment fragment) {
        super.onAttachFragment(fragment);
        if (fragment instanceof AMapFragment) {
            mAMapFragment = (AMapFragment) fragment;
        } else if (fragment instanceof OrderDetailFragment) {
            mOrderDetailFragment = (OrderDetailFragment) fragment;
        }
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
    }
}
